package one.stand.controller;

import one.stand.entity.websocket.CompanyInfoEntity;
import one.stand.model.ResultModel;
import one.stand.request.BusinessCardRequest;
import one.stand.request.UserCommonRequest;
import one.stand.response.BusinessCardResponse;
import one.stand.response.GetCompanyStaffResponse;
import one.stand.response.UserCommonResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 企业成员
 *
 * @author Administrator
 */
@RestController
@RequestMapping("businessCard")
public class BusinessCardController extends BaseController {

    /**
     * crm端查询名片列表
     *
     * @param request
     * @return
     */
    @PostMapping("selectBusinessCardList")
    public ResultModel<List<BusinessCardResponse>> selectBusinessCardList(@RequestBody BusinessCardRequest request) {
        return businessCardService.selectBusinessCardList(request);
    }

    /**
     * 修改用户名片欢迎语
     *
     * @param request
     * @return
     */
    @PostMapping("updateCardWelcomeSpeech")
    public ResultModel<Boolean> updateCardWelcomeSpeech(@RequestBody BusinessCardRequest request) {
        return businessCardService.updateCardWelcomeSpeech(request);
    }



    /**
     * 审核名片
     *
     * @param request
     * @return
     */
    @PostMapping("auditBusinessCard")
    public ResultModel auditBusinessCard(@RequestBody BusinessCardRequest request) {
        return businessCardService.auditBusinessCard(request);
    }

    /**
     * 获取公司员工
     *
     * @param request
     * @return
     */
    @PostMapping("getCompanyStaffList")
    public ResultModel<Map<String, Object>> getCompanyStaffList(@RequestBody BusinessCardRequest request) {
        return businessCardService.getCompanyStaffList(request);
    }

    /**
     * 得到公司员工信息
     *
     * @param request
     * @return
     */
    @PostMapping("getCompanyStaffInfo")
    public ResultModel<GetCompanyStaffResponse> getCompanyStaffInfo(@RequestBody BusinessCardRequest request) {
        return businessCardService.getCompanyStaffInfo(request);
    }

    /**
     * 员工列表
     *
     * @param request
     * @return
     */
    @PostMapping("getList")
    public ResultModel<List<BusinessCardResponse>> getList(@RequestBody BusinessCardRequest request) {
        return businessCardService.getList(request);
    }

    /**
     * 设置默认名片
     */
    @PostMapping("setDefaultBusinessCard")
    public ResultModel<Boolean> setDefaultBusinessCard(@RequestBody BusinessCardRequest request) {
        return businessCardService.setDefaultBusinessCard(request);
    }

    /**
     * 是否是小程序的拥有者
     * @param request
     * @return
     */
    @PostMapping("isMiniProgramOwner")
    public ResultModel<Boolean> isMiniProgramOwner(@RequestBody BusinessCardRequest request) {
        return businessCardService.isMiniProgramOwner(request);
    }

    /**
     * 获取成员信息
     *
     * @return
     */
    @PostMapping("getCompanyUserInfo")
    public ResultModel getCompanyUserInfo(@RequestBody BusinessCardRequest request) {
        return businessCardService.getCompanyUserInfo(request);
    }

    /**
     * 消息服务获取公司信息
     *
     * @param cardId
     * @return
     */
    @PostMapping("messageGetCompanyInfo")
    public ResultModel<CompanyInfoEntity> messageGetCompanyInfo(Long cardId) {
        return businessCardService.messageGetCompanyInfo(cardId);
    }

    /**
     * 得到名片海报
     */
    @PostMapping("getCardPoster")
    public ResultModel getCardPoster(@RequestBody BusinessCardRequest request) {
        return businessCardService.getCardPoster(request);
    }

    /**
     * 得到名片二维码
     */
    @PostMapping("getWxTwoCode")
    public ResultModel getWxTwoCode(@RequestBody BusinessCardRequest request) {
        return businessCardService.getWxTwoCode(request);
    }

    /**
     * 根据userId  获取名片电话号码
     * @param request
     * @return
     */
    @PostMapping("getCardPhone")
    public ResultModel<BusinessCardResponse> getCardPhone(@RequestBody BusinessCardRequest request) {
        return businessCardService.getCardPhone(request);
    }

    /**
     * 发送给user端的客戶
     *
     * @param sendUserId 发送人userId
     * @param receiveUserId 接收人userId
     * @param text 聊天消息提示內容
     * @param type 0未读消息提示，1联系方式提示
     * @return
     */
    @PostMapping("/unreadMessage")
    public ResultModel unreadMessage(@RequestParam(value="sendUserId") Integer sendUserId, @RequestParam(value="receiveUserId") Integer receiveUserId, @RequestParam(value="text") String text, @RequestParam(value="type") Integer type) {
        return businessCardService.unreadMessage(sendUserId, receiveUserId, text, type);
    }

    /**
     * 验证名片是否过期
     *
     * @param request
     * @return
     */
    @PostMapping("/verifyExpired")
    public ResultModel<Long> verifyExpired(@RequestBody BusinessCardRequest request) {
        return businessCardService.verifyExpired(request);
    }

    /**
     * 用户可接收微信推送次数
     *
     * @param request
     * @return
     */
    @PostMapping("/formIdCount")
    public ResultModel<Integer> formIdCount(@RequestBody BusinessCardRequest request) {
        return businessCardService.formIdCount(request);
    }

    /**
     * 清空微信推送次数
     *
     * @param request
     * @return
     */
    @PostMapping("/delFormId")
    public ResultModel<Boolean> delFormId(@RequestBody BusinessCardRequest request) {
        return businessCardService.delFormId(request);
    }

    /**
     * 查询用户常用语（3.2版本迭代）
     *
     * @param request
     * @return
     */
    @PostMapping("/selectUserCommonList")
    public ResultModel<List<UserCommonResponse>> selectUserCommonList(@RequestBody UserCommonRequest request) {
        return businessCardService.selectUserCommonList(request);
    }

    /**
     * 新增/修改用户常用语（3.2版本迭代）
     *
     * @param request
     * @return
     */
    @PostMapping("/insertUserCommonList")
    public ResultModel<Boolean> insertUserCommonList(@RequestBody UserCommonRequest request) {
        return businessCardService.insertUserCommonList(request);
    }

    /**
     * 删除用户常用语（3.2版本迭代）
     *
     * @param request
     * @return
     */
    @PostMapping("/delUserCommonList")
    public ResultModel<Boolean> delUserCommonList(@RequestBody UserCommonRequest request) {
        return businessCardService.delUserCommonList(request);
    }

    /**
     * 上下移动用户常用语（3.2版本迭代）
     *
     * @param request
     * @return
     */
    @PostMapping("/moveUserCommon")
    public ResultModel<Boolean> moveUserCommon(@RequestBody UserCommonRequest request) {
        return businessCardService.moveUserCommon(request);
    }
}
